package cn.wp.common.core.plugin.verification;

import cn.wp.common.core.cache.WpCacheGroup;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;
import org.springframework.stereotype.Service;

/**
 * 验证码数据访问层
 * Created by chenyb on 2019/10/18
 */
@Repository
public class VerificationCodeDao {

    @Autowired
    private WpCacheGroup cacheGroup;

    /**
     * 保存验证码
     * @param randomStr
     * @param code
     * @return
     */
    public String insertCode(String randomStr,String code){
        cacheGroup.getCache("ver-code").set(randomStr,code);
        return code;
    }

    /**
     * 查询验证码
     * @param randomStr
     * @return
     */
    public String selectCode(String randomStr){
        String code = cacheGroup.getCache("ver-code").get(randomStr);
        return code;
    }

}
